package com.smartcanteen.setmeal.mapper;


import com.smartcanteen.setmeal.domain.entity.SetmealDish;
import com.smartcanteen.setmeal.domain.entity.SetmealDishWithPic;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    void insertBatch(@Param("setmealDishes") List<SetmealDish> setmealDishes);

    @Select("select * from sc_setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getDishesBySetmealId(Integer id);

    @Delete("delete from sc_setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Integer setmealId);

    void deleteBatch(@Param("ids")List<Integer> ids);

    @Select("select sd.*, d.image from sc_setmeal_dish sd left join sc_dish d on sd.dish_id = d.id where sd.setmeal_id = #{id}")
    List<SetmealDishWithPic> getDishesWithPic(Integer id);

    List<Integer> getSetmealIdsByDishIds(@Param("ids") List<Integer> ids);
}
